package torres.entity;

import torres.map.*;

/**
 * @author Torres
 * Represents the player character and includes user-related statistics.
 */
@SuppressWarnings("serial")
public class Avatar extends Entity {

	/**
	 * The main avatar constructor which makes the avatar.
	 * @param name the name of the avatar
	 * @param job the occupation of the avatar {SNEAK, SUMMONER, SMASHER}
	 */
	public Avatar(String name, Occupation job) {
		super(name, job);
		this.setImageName("llamaE.png");
	}
	
	/**
	 * @param name the name of the avatar
	 * @param job the occupation of the avatar {SNEAK, SUMMONER, SMASHER}
	 * @param location the location of where the avatar will be placed on the map
	 */
	public Avatar(String name, Occupation job, Location location) {
		this(name,job);
		super.setLocation(location);
	}
	
	/* (non-Javadoc)
	 * @see torres.entity.Entity#toString()
	 */
	public String toString() {
		//return "Avatar's name is: " + this.getName() + "\ncurrlife = " + this.getCurrLife() + "\nnumber of deaths: " + numberDeaths + "\ntime played: " + timePlayed;
		return this.getName();
	}
	
	/* (non-Javadoc)
	 * @see torres.entity.Entity#updateLevel()
	 */
	public void updateLevel(){
		int currLevel = this.getLevel();
		int newLevel = (int) (Math.pow(this.getExperience(),(1/2.5))+1);
		int levelDiff = newLevel - currLevel;
		if( levelDiff > 0 && newLevel < 100) {
			this.setIntellect((int) (this.getIntellect()*1.05 + this.getOccupation().getIntellectMultiplier()*levelDiff));
			this.setStrength((int) (this.getStrength()*1.05 + this.getOccupation().getStrengthMultiplier()*levelDiff));
			this.setAgility((int) (this.getAgility()*1.05 + this.getOccupation().getAgilityMultiplier()*levelDiff));
			this.setHardiness((int) (this.getHardiness()*1.1));
			this.setLevel(newLevel);
			this.setMovement((int) (this.getMovement() + Math.sqrt(this.getAgility()*.05)*levelDiff));
			this.setCurrLife(this.getMaxLife());
			this.setCurrMana(this.getMaxMana());
			if(this.getLevel()>=50)
				this.setImageName("dragon" + this.getDirection() + ".png");
		}
	}
	
}
